﻿using System;

namespace BG.DAL.Helpers
{
    public class DateExtension
    {
        public static DateTime FirstDayOfMonthFromDateTime(DateTime dateTime)
        {
            return new DateTime(dateTime.Year, dateTime.Month, 1);
        }

        public static DateTime LastDayOfMonthFromDateTime(DateTime dateTime)
        {
            DateTime firstDayOfTheMonth = new DateTime(dateTime.Year, dateTime.Month, 1);
            return firstDayOfTheMonth.AddMonths(1).AddDays(-1);
        }

        public static int Compare(DateTime dt1, DateTime dt2)
        {
            // return -1 = less
            // return 0 = equal
            // return 1 = more
            int allDay1 = dt1.DayOfYear;
            int allDay2 = dt2.DayOfYear;


            if (allDay1 > allDay2)
                return 1;
            else if (allDay1 < allDay2)
                return -1;
            else
                return 0;
        }
    }
}
